--未曾褫冠
local weicengchiguan = fk.CreateSkill {
    name = "mcdh_weicengchiguan",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

weicengchiguan:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(self) or data.from ~= player.id or player.phase ~= Player.Play then return false end
        return data.firstTarget and table.find(
                data:getAllTargets(),
                function(p)
                    return p ~= player and p:getHandcardNum() > 0
                end
        )
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = room:askToChoosePlayers(player, {
            targets = table.filter(
                data:getAllTargets(),
              function(p)
                return p ~= player and p:getHandcardNum() > 0
              end
            ),
            min_num = 1,
            max_num = 1,
            prompt = "#mcdh_weicengchiguan-invoke",
            skill_name = self.name,
            cancelable = true
          })
        if #targets > 0 then
            self.cost_data = targets[1]
            return true
        end
        return false
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to =self.cost_data
        local cid = room:askForCardChosen(player, to, "h", self.name, "#mcdh_weicengchiguan-choice:" .. self.cost_data)
        room:obtainCard(player.id, cid, false, fk.ReasonPrey)
        local card = Fk:getCardById(cid)
        if not card.is_damage_card and card.sub_type ~= Card.SubtypeWeapon then
            room:setPlayerMark(player, "@@mcdh_weicengchiguan-turn", 1)
        end
    end,
})

weicengchiguan:addEffect('prohibit',{
    prohibit_use = function(self, player, card)
        return player:getMark("@@mcdh_weicengchiguan-turn") ~= 0
    end,
    prohibit_response = function(self, player, card)
        return player:getMark("@@mcdh_weicengchiguan-turn") ~= 0
    end,
})

Fk:loadTranslationTable {
    ["mcdh_weicengchiguan"] = "存冕",
    [":mcdh_weicengchiguan"] = "『未曾褫(chǐ)冠』<br>你的出牌阶段内，当你使用牌指定目标后，你可以获得一个目标的一张手牌，若此牌不为伤害牌和武器牌，你本回合不能再使用或打出牌。",
    ["#mcdh_weicengchiguan-invoke"] = "未曾褫冠:选择一个目标角色，你将要获得其一张手牌",
    ["#mcdh_weicengchiguan-choice"] = "未曾褫冠:获得 %src 的一张手牌",
    ["@@mcdh_weicengchiguan-turn"] = "未曾褫冠",
}

return weicengchiguan